﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class System_Share_Default : System.Web.UI.MasterPage
{

    public string AddHRef
    {
        set { this.add.HRef = value; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Page.Title = "";
            SitePath sitepath = new SitePath();
            sitepath.GetPaths(SiteMap.CurrentNode);
            List<SitePath> items = sitepath.Items;
            foreach (SitePath item in items)
            {
                path.Text = path.Text == "" ? item.Title : item.Title + ">>" + path.Text;
            }
        }
    }

    private class SitePath
    {
        private string title;
        private string url;
        private List<SitePath> items = new List<SitePath>();
        public string Title
        {
            get { return this.title; }
        }

        public string Url
        {
            get { return this.url; }
        }
        public List<SitePath> Items
        {
            get { return this.items; }
        }
        public SitePath() { }
        public SitePath(string title, string url)
        {
            this.title = title;
            this.url = url;
        }

        public void GetPaths(SiteMapNode node)
        {
            if (node != null)
            {
                SitePath item = new SitePath(node.Title, node.Url);
                items.Add(item);
                GetPaths(node.ParentNode);
            }
        }
    }
}
